﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Epic.TakeHome.Al  {
  public partial class InvGUI : Form {
    OpenFileDialog _fileDialog = new OpenFileDialog();
    InvSystem _system = new InvSystem();

    public InvGUI() {
      InitializeComponent();
      _fileDialog.Filter = "Epic Inventory System files (*.eis)|*.eis";
    }

    private void InvGUI_Load(object sender, EventArgs e) {

    }

    private void buttonNew_Click(object sender, EventArgs e) {
      _system.addProduct("ABC", 1, 1, 1);
    }

    private void buttonLoad_Click(object sender, EventArgs e) {
      if (_fileDialog.ShowDialog() != DialogResult.OK) {
        return;
      }

      FileInfo file = new FileInfo(_fileDialog.FileName);
      FileManager fm = new FileManager(file);
      _system = new InvSystem();
      fm.Load (_system);
    }

    private void buttonSave_Click(object sender, EventArgs e) {
      if (_fileDialog.ShowDialog() != DialogResult.OK) {
        return;
      }

      FileInfo file = new FileInfo(_fileDialog.FileName);
      FileManager fm = new FileManager(file);
      fm.SaveTo(_system);
    }

  }
}
